package com.edu.exam.enums;

/**
 * 成绩导出任务类型枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeExportTaskType {
    /** 单次导出 */
    SINGLE("SINGLE", "单次导出"),
    /** 批量导出 */
    BATCH("BATCH", "批量导出"),
    /** 定时导出 */
    SCHEDULED("SCHEDULED", "定时导出"),
    /** 增量导出 */
    INCREMENTAL("INCREMENTAL", "增量导出"),
    /** 全量导出 */
    FULL("FULL", "全量导出"),
    /** 条件导出 */
    CONDITIONAL("CONDITIONAL", "条件导出"),
    /** 模板导出 */
    TEMPLATE("TEMPLATE", "模板导出"),
    /** 自定义导出 */
    CUSTOM("CUSTOM", "自定义导出");

    private final String code;
    private final String description;

    GradeExportTaskType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeExportTaskType fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeExportTaskType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeExportTaskType fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeExportTaskType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}